package ${package}.view

import br.com.me.ceap.web.ui.html.DivLayout
import br.com.me.ceap.web.ui.html.Form
import br.com.me.ceap.web.ui.html.MEGrid
import br.com.me.ceap.web.view.page.AbstractTitledPageView
import ${package}.pojo.ExamplePOJO
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 * Example view with a lot of components.
 */
class ExampleManyComponentsView extends AbstractTitledPageView {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private String customRootName;
    private Object someObjectForEditing;

    ExampleManyComponentsView(final String customRootName, final Object someObjectForEditing) {
        this.customRootName = customRootName
        this.someObjectForEditing = someObjectForEditing
    }


    @Override
    protected String getTitle() {
        return "Example with many components!";
    }

    @Override
    protected void prepareDiv(final DivLayout mainDiv) {
        mainDiv.addChildTag(new MEGrid("someId").autoAddColumns(ExamplePOJO.class).setBaseURLData("/$customRootName/do/example/getSomeExampleGridJSONData"));
        mainDiv.addChildTag(new Form().setModel(someObjectForEditing).setAutoFields(true));
    }
}
